<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>历史数据 - Modbus监控系统</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            padding: 20px;
        }

        .container {
            max-width: 1400px;
            margin: 0 auto;
        }

        .header {
            background: white;
            padding: 20px 30px;
            border-radius: 10px;
            margin-bottom: 20px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }

        .header h1 {
            font-size: 24px;
            color: #333;
            margin-bottom: 20px;
        }

        .filter-panel {
            background: #f8fafc;
            padding: 20px;
            border-radius: 8px;
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 15px;
            align-items: end;
        }

        .form-group {
            display: flex;
            flex-direction: column;
        }

        .form-group label {
            margin-bottom: 8px;
            color: #666;
            font-size: 14px;
            font-weight: 500;
        }

        .form-group select,
        .form-group input {
            padding: 10px;
            border: 2px solid #e5e7eb;
            border-radius: 5px;
            font-size: 14px;
        }

        .form-group select:focus,
        .form-group input:focus {
            outline: none;
            border-color: #3b82f6;
        }

        .btn {
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 14px;
            font-weight: 500;
            transition: all 0.3s;
        }

        .btn-primary {
            background: #3b82f6;
            color: white;
        }

        .btn-primary:hover {
            background: #2563eb;
        }

        .btn-success {
            background: #10b981;
            color: white;
        }

        .btn-success:hover {
            background: #059669;
        }

        .quick-filters {
            display: flex;
            gap: 10px;
            margin-top: 15px;
        }

        .quick-btn {
            padding: 6px 15px;
            border: 1px solid #ddd;
            background: white;
            border-radius: 20px;
            cursor: pointer;
            font-size: 13px;
            transition: all 0.3s;
        }

        .quick-btn:hover {
            background: #3b82f6;
            color: white;
            border-color: #3b82f6;
        }

        .data-table-container {
            background: white;
            border-radius: 10px;
            padding: 20px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            margin-bottom: 20px;
        }

        .table-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }

        .table-header h2 {
            font-size: 18px;
            color: #333;
        }

        .table-actions {
            display: flex;
            gap: 10px;
        }

        table {
            width: 100%;
            border-collapse: collapse;
        }

        thead {
            background: #f8fafc;
        }

        th {
            padding: 15px;
            text-align: left;
            font-weight: 600;
            color: #666;
            border-bottom: 2px solid #e5e7eb;
            font-size: 14px;
        }

        td {
            padding: 15px;
            border-bottom: 1px solid #f1f3f5;
            font-size: 14px;
            color: #333;
        }

        tbody tr:hover {
            background: #f8fafc;
        }

        .value-cell {
            font-weight: 600;
        }

        .value-temp {
            color: #ef4444;
        }

        .value-pressure {
            color: #3b82f6;
        }

        .value-flow {
            color: #10b981;
        }

        .pagination {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-top: 20px;
            padding-top: 20px;
            border-top: 1px solid #e5e7eb;
        }

        .pagination-info {
            color: #666;
            font-size: 14px;
        }

        .pagination-controls {
            display: flex;
            gap: 5px;
        }

        .page-btn {
            padding: 8px 12px;
            border: 1px solid #e5e7eb;
            background: white;
            border-radius: 5px;
            cursor: pointer;
            font-size: 14px;
            transition: all 0.3s;
        }

        .page-btn:hover {
            background: #f8fafc;
        }

        .page-btn.active {
            background: #3b82f6;
            color: white;
            border-color: #3b82f6;
        }

        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
            margin-bottom: 20px;
        }

        .stat-card {
            background: white;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }

        .stat-card h3 {
            font-size: 14px;
            color: #666;
            margin-bottom: 10px;
        }

        .stat-value {
            font-size: 28px;
            font-weight: bold;
            color: #333;
        }

        .stat-change {
            font-size: 12px;
            margin-top: 5px;
        }

        .stat-change.up {
            color: #ef4444;
        }

        .stat-change.down {
            color: #10b981;
        }
    </style>
</head>

<body>
    <div class="container">
        <!-- 顶部筛选面板 -->
        <div class="header">
            <h1>📈 历史数据查询</h1>
            <div class="filter-panel">
                <div class="form-group">
                    <label>选择设备</label>
                    <select>
                        <option>全部设备</option>
                        <option selected>PLC_01 (192.168.1.100)</option>
                        <option>PLC_02 (192.168.1.101)</option>
                        <option>PLC_03 (192.168.1.102)</option>
                    </select>
                </div>

                <div class="form-group">
                    <label>开始时间</label>
                    <input type="datetime-local" value="2025-10-29T09:00">
                </div>

                <div class="form-group">
                    <label>结束时间</label>
                    <input type="datetime-local" value="2025-10-29T15:00">
                </div>

                <div class="form-group">
                    <label>数据类型</label>
                    <select>
                        <option>全部数据</option>
                        <option>温度</option>
                        <option>压力</option>
                        <option>流量</option>
                    </select>
                </div>

                <div class="form-group">
                    <label>&nbsp;</label>
                    <button class="btn btn-primary">🔍 查询</button>
                </div>

                <div class="form-group">
                    <label>&nbsp;</label>
                    <button class="btn btn-success">📥 导出 CSV</button>
                </div>
            </div>

            <div class="quick-filters">
                <span style="color: #666; font-size: 14px; margin-right: 10px;">快捷选择：</span>
                <button class="quick-btn">今天</button>
                <button class="quick-btn">最近7天</button>
                <button class="quick-btn">最近30天</button>
                <button class="quick-btn">本月</button>
                <button class="quick-btn">上月</button>
            </div>
        </div>

        <!-- 统计卡片 -->
        <div class="stats-grid">
            <div class="stat-card">
                <h3>🌡️ 温度统计</h3>
                <div class="stat-value" style="color: #ef4444;">68.3℃</div>
                <div
                    style="display: flex; justify-content: space-between; margin-top: 10px; font-size: 13px; color: #666;">
                    <span>最高: <strong style="color: #ef4444;">72.1℃</strong></span>
                    <span>最低: <strong style="color: #3b82f6;">65.2℃</strong></span>
                </div>
                <div class="stat-change up">↑ 比昨日 +0.8℃</div>
            </div>
            <div class="stat-card">
                <h3>💨 压力统计</h3>
                <div class="stat-value" style="color: #3b82f6;">319.5 kPa</div>
                <div
                    style="display: flex; justify-content: space-between; margin-top: 10px; font-size: 13px; color: #666;">
                    <span>最高: <strong style="color: #ef4444;">325.8 kPa</strong></span>
                    <span>最低: <strong style="color: #3b82f6;">312.4 kPa</strong></span>
                </div>
                <div class="stat-change down">↓ 比昨日 -1.2 kPa</div>
            </div>
            <div class="stat-card">
                <h3>💧 流量统计</h3>
                <div class="stat-value" style="color: #10b981;">45.52 L/min</div>
                <div
                    style="display: flex; justify-content: space-between; margin-top: 10px; font-size: 13px; color: #666;">
                    <span>最高: <strong style="color: #ef4444;">48.35 L/min</strong></span>
                    <span>最低: <strong style="color: #3b82f6;">42.18 L/min</strong></span>
                </div>
                <div class="stat-change up">↑ 比昨日 +0.3 L/min</div>
            </div>
            <div class="stat-card">
                <h3>📊 数据记录总数</h3>
                <div class="stat-value" style="color: #333;">21,600</div>
                <div style="margin-top: 10px; font-size: 13px; color: #666;">
                    查询范围: 6小时 · 采样频率: 1秒/次
                </div>
                <div class="stat-change" style="color: #666;">时间跨度: 2025-10-29 09:00 - 15:00</div>
            </div>
        </div>

        <!-- 数据表格 -->
        <div class="data-table-container">
            <div class="table-header">
                <h2>📊 数据记录明细</h2>
                <div class="table-actions">
                    <select style="padding: 8px; border: 1px solid #ddd; border-radius: 5px;">
                        <option>每页显示 20 条</option>
                        <option>每页显示 50 条</option>
                        <option>每页显示 100 条</option>
                    </select>
                </div>
            </div>

            <table>
                <thead>
                    <tr>
                        <th>序号</th>
                        <th>时间戳</th>
                        <th>设备名称</th>
                        <th>温度 (℃)</th>
                        <th>压力 (kPa)</th>
                        <th>流量 (L/min)</th>
                        <th>状态</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>1</td>
                        <td>2025-10-29 14:59:58</td>
                        <td>PLC_01</td>
                        <td class="value-cell value-temp">68.5</td>
                        <td class="value-cell value-pressure">320.2</td>
                        <td class="value-cell value-flow">45.67</td>
                        <td><span style="color: #10b981;">✓ 正常</span></td>
                    </tr>
                    <tr>
                        <td>2</td>
                        <td>2025-10-29 14:59:57</td>
                        <td>PLC_01</td>
                        <td class="value-cell value-temp">68.7</td>
                        <td class="value-cell value-pressure">318.9</td>
                        <td class="value-cell value-flow">45.82</td>
                        <td><span style="color: #10b981;">✓ 正常</span></td>
                    </tr>
                    <tr>
                        <td>3</td>
                        <td>2025-10-29 14:59:56</td>
                        <td>PLC_01</td>
                        <td class="value-cell value-temp">68.6</td>
                        <td class="value-cell value-pressure">321.1</td>
                        <td class="value-cell value-flow">45.55</td>
                        <td><span style="color: #10b981;">✓ 正常</span></td>
                    </tr>
                    <tr>
                        <td>4</td>
                        <td>2025-10-29 14:59:55</td>
                        <td>PLC_01</td>
                        <td class="value-cell value-temp">68.4</td>
                        <td class="value-cell value-pressure">319.8</td>
                        <td class="value-cell value-flow">45.71</td>
                        <td><span style="color: #10b981;">✓ 正常</span></td>
                    </tr>
                    <tr>
                        <td>5</td>
                        <td>2025-10-29 14:59:54</td>
                        <td>PLC_01</td>
                        <td class="value-cell value-temp">68.8</td>
                        <td class="value-cell value-pressure">320.5</td>
                        <td class="value-cell value-flow">45.63</td>
                        <td><span style="color: #10b981;">✓ 正常</span></td>
                    </tr>
                    <tr>
                        <td>6</td>
                        <td>2025-10-29 14:59:53</td>
                        <td>PLC_01</td>
                        <td class="value-cell value-temp">69.2</td>
                        <td class="value-cell value-pressure">322.3</td>
                        <td class="value-cell value-flow">46.15</td>
                        <td><span style="color: #f59e0b;">⚠ 偏高</span></td>
                    </tr>
                    <tr>
                        <td>7</td>
                        <td>2025-10-29 14:59:52</td>
                        <td>PLC_01</td>
                        <td class="value-cell value-temp">68.3</td>
                        <td class="value-cell value-pressure">318.7</td>
                        <td class="value-cell value-flow">45.48</td>
                        <td><span style="color: #10b981;">✓ 正常</span></td>
                    </tr>
                    <tr>
                        <td>8</td>
                        <td>2025-10-29 14:59:51</td>
                        <td>PLC_01</td>
                        <td class="value-cell value-temp">68.5</td>
                        <td class="value-cell value-pressure">319.4</td>
                        <td class="value-cell value-flow">45.59</td>
                        <td><span style="color: #10b981;">✓ 正常</span></td>
                    </tr>
                    <tr>
                        <td>9</td>
                        <td>2025-10-29 14:59:50</td>
                        <td>PLC_01</td>
                        <td class="value-cell value-temp">68.7</td>
                        <td class="value-cell value-pressure">320.1</td>
                        <td class="value-cell value-flow">45.72</td>
                        <td><span style="color: #10b981;">✓ 正常</span></td>
                    </tr>
                    <tr>
                        <td>10</td>
                        <td>2025-10-29 14:59:49</td>
                        <td>PLC_01</td>
                        <td class="value-cell value-temp">68.4</td>
                        <td class="value-cell value-pressure">319.2</td>
                        <td class="value-cell value-flow">45.61</td>
                        <td><span style="color: #10b981;">✓ 正常</span></td>
                    </tr>
                </tbody>
            </table>

            <!-- 分页 -->
            <div class="pagination">
                <div class="pagination-info">
                    显示 1-10 条，共 21,600 条记录
                </div>
                <div class="pagination-controls">
                    <button class="page-btn">«</button>
                    <button class="page-btn active">1</button>
                    <button class="page-btn">2</button>
                    <button class="page-btn">3</button>
                    <button class="page-btn">4</button>
                    <button class="page-btn">5</button>
                    <button class="page-btn">...</button>
                    <button class="page-btn">2160</button>
                    <button class="page-btn">»</button>
                </div>
            </div>
        </div>
    </div>

    <script>
        // 快捷时间选择
        document.querySelectorAll('.quick-btn').forEach(btn => {
            btn.addEventListener('click', function () {
                alert('已选择: ' + this.textContent);
            });
        });
    </script>
</body>

</html>